#!/bin/bash
# Author: Karol Krizka
# Last Modified: February 5, 2010
#
# Reruns the measureMetrics.sh script on every single revision found in the repository.
# It works by checking out revision 1 in a temporary folder, running measureMetrics.sh,
# updating to revision 2, running measureMetrics.sh until we reach the current revision.
#
# It is possible to specify the top revision manually as the first
# argument to the script.
#
# The output is shown in stdout

if [ "x${1}x" == "xx" ]
then
# Current revision
    SVNREVISION=`svn info | awk '/Revision/ {print $2}'`
else
    SVNREVISION=${1}
fi

#if [ -d green-power-read-only ]
#then
#    rm -rf green-power-read-only
#fi

WORKDIR=`pwd`

TMPDIR=`mktemp -d`
cd ${TMPDIR}

svn checkout -r1 http://green-power.googlecode.com/svn/trunk/ green-power-read-only >> /dev/null
cd green-power-read-only
${WORKDIR}/measureMetrics.sh # revision 1

for i in `seq 2 ${SVNREVISION}`
do
    svn up -r ${i} >> /dev/null
    ${WORKDIR}/measureMetrics.sh
done

rm -rf ${TMPDIR}
cd ${WORKDIR}